/*
 * Copyright (C) 2013～2023 上海颐凡软件科技有限公司
 * Yfann Software Technology (Shanghai) Co.,LTD
 * All Rights Reserved.
 * 公司网址: www.yfann.com
 * 365IT教育网，成就您优秀架构师之梦！
 * 平台网址: www.365itedu.com
 */
package com.yfann.web.base.sys.action;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.yfann.sword.web.fwk.Service;
import com.yfann.sword.web.fwk.action.ActionServiceSupport;
import com.yfann.sword.web.fwk.exception.ApplicationException;
import com.yfann.sword.web.fwk.exception.CheckErrorException;
import com.yfann.sword.web.fwk.util.ExceptionUtil;
import com.yfann.web.base.sys.checker.SYS0101S01CheckerUEC;
import com.yfann.web.base.sys.form.SYS0101S01Form;

/**
 * 登录页面业务处理类。
 * @since V1.0
 * @version 版本1.0 2013.10.20
 * @author 颜廷吉
 */
public class SYS0101S01EventAction extends ActionServiceSupport {

    /**
     * 日志
     */
    Log log = LogFactory.getLog(SYS0101S01EventAction.class);

    /**
     * 序列号
     */
    private static final long serialVersionUID = 1777774660354147379L;

    /**
     * 验证错误页面
     */
    private static final String INPUT_EVENT = "forwardInput";

    /**
     * FORM容器
     */
    private SYS0101S01Form sys0101S01Form;

    /**
     * 登录业务逻辑处理
     */
    private Service sys0101S01LoginService;
    private Service sys0101S01RefreshService;

    public void setSys0101S01RefreshService(Service sys0101s01RefreshService) {
        sys0101S01RefreshService = sys0101s01RefreshService;
    }

    /**
     * 设定登录页面FORM容器。
     * @param sys0101S01Form APP01SC01Form
     */
    public void setSys01SC01Form(SYS0101S01Form sys0101S01Form) {
        this.sys0101S01Form = sys0101S01Form;
    }

    /**
     * 登录页面输入项目验证处理。
     * @param enventMethod String
     * @throws Exception Exception
     */
    public void checkField(String enventMethod) throws Exception {
        new SYS0101S01CheckerUEC().check(sys0101S01Form, enventMethod);
    }

    public SYS0101S01Form getSys0101S01Form() {
        return sys0101S01Form;
    }

    public void setSys0101S01Form(SYS0101S01Form sys0101s01Form) {
        sys0101S01Form = sys0101s01Form;
    }

    public void setSys0101S01LoginService(Service sys0101S01LoginService) {
        this.sys0101S01LoginService = sys0101S01LoginService;
    }

    /**
     * 登录页面登录业务逻辑处理。
     * @throws Exception Exception
     * @return String
     */
    public String loginEvent() throws Exception {
        String serviceResult = "";

        try {
            // 输入验证处理
            checkField(INPUT_EVENT);
            // 业务逻辑调用
            serviceResult = sys0101S01LoginService.executeService();
        } catch (CheckErrorException e) {
            serviceResult = e.getErrorEventMethod();
            log.info(ExceptionUtil.getStackTrace(e));
        } catch (ApplicationException e) {
            serviceResult = e.getErrorEventMethod();
            log.info(ExceptionUtil.getStackTrace(e));
        }

        return serviceResult;
    }

    /**
     * 登录页面登录业务逻辑处理。
     * @throws Exception Exception
     * @return String
     */
    public String execute() throws Exception {
        String serviceResult = "success";
        serviceResult = sys0101S01RefreshService.executeService();
        return serviceResult;
    }
    
    /**
     * 登录页面登录业务逻辑处理。
     * @throws Exception Exception
     * @return String
     */
    public String registEvent() throws Exception {
        String serviceResult = "forwardRegist";

        return serviceResult;
    }
}
